/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interpreter;

/**
 *
 * @author Jenny Patrick
 */
public abstract class Expresion {
    
    public abstract String uno();
    public abstract String cuatro();
    public abstract String cinco();
    public abstract String nueve();
    public abstract int multiplo();
    
    public void interpreter(Contexto contexto){
        if(contexto.entrada.startsWith(nueve())){
            contexto.salida +=(9*multiplo());
            contexto.entrada = contexto.entrada.substring(2);
        }
        else if(contexto.entrada.startsWith(cuatro())){
            contexto.salida += (4* multiplo());
            contexto.entrada = contexto.entrada.substring(2);
        }
        else if(contexto.entrada.startsWith(cinco())){
            contexto.salida += (5* multiplo());
            contexto.entrada = contexto.entrada.substring(1);
        }
        while(contexto.entrada.startsWith(uno())){
            contexto.salida += (1*multiplo());
            contexto.entrada = contexto.entrada.substring(1);
        }
    }
    
}
